{include file="Public:header2"/}
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="get" class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline" style="width: 300px;margin-left: 0px">
                        <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入预售标题" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn layuiadmin-btn-useradmin mmm" lay-submit lay-filter="LAY-user-front-search">
                        <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                    </button>
                </div>
            </div>
        </form>
        <div class="layui-card-body">
            <xblock>
                <div style="padding-bottom: 10px;">
                    <a class="layui-btn" onclick="yushou_rili_add()">添加预售日历</a>
                    <span style="line-height:40px;float:right;">共有数据： {$count}条</span>
                </div>
            </xblock>
            <table class="layui-table" style="text-align:center">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>标题</th>
                    <th>图片</th>
                    <th>盒子</th>
                    <th>预售时间</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo['id']}</td>
                    <td>{$vo['title']}</td>
                    <td><img src="{PHP} echo imageUrl($vo['imgurl']){/php}" style="width:60px;height:60px;"></td>
                    <td>{$vo['goods_title']}</td>
                    <td>{$vo['sale_time']}</td>
                    <td>{$vo['sort']}</td>
                    <td>
                        <a style="text-decoration:none" onclick="yushou_rili_edit({$vo.id})" class="layui-btn layui-btn-radius layui-btn-normal layui-btn-xs">
                            <i class="layui-icon layui-icon-edit"></i>编辑
                        </a>
                        <a style="text-decoration:none" onClick="del({$vo.id})" class="layui-btn layui-btn-danger layui-btn-radius layui-btn-xs">删除</a>

                    </td>
                </tr>
                {/volist}

                {if condition="empty($list)"}
                <tr><td colspan='10' style="text-align:center;">暂时没有数据！</td></tr>
                {/if}
                </tbody>
            </table>
            <div class="layui-box layui-laypage layui-laypage-default">
                {$page|raw}
            </div>
        </div>
    </div>
</div>
{include file="Public:footer"/}
<script type="text/javascript">
    layui.use(['layer','laydate'], function(){
        var $ = layui.$;
        var laydate = layui.laydate;
        //日期时间范围
        laydate.render({
            elem: '#range_time'
            ,type: 'datetime'
            ,range: true
        });
    })


    //添加预售日历
    function yushou_rili_add() {
        var url  = "{:url('/admin/yushou_rili_add')}";
        layer.open({
            type: 2,
            title: '添加预售日历',
            shadeClose: false,
            shade: 0.3,
            area: ['70%', '90%'],
            content: url,
        });
    }

    //编辑预售日历
    function yushou_rili_edit(id) {
        var url  = "{:url('/admin/yushou_rili_edit?id="+id+"')}";
        layer.open({
            type: 2,
            title: '编辑预售日历',
            shadeClose: false,
            shade: 0.3,
            area: ['70%', '90%'],
            content: url,
        });
    }

    //上下架
    function del(id){
        layer.confirm('确认要执行删除操作吗？',function(){
            var url = "{:url('/admin/yushou_rili_del')}";
            var load=layer.load(2);
            var $ = layui.$;
            $.post(url,{"id":id},function(data){
                if(data.status == 1){
                    layer.msg('删除成功',{icon:1,time:1000},function(){
                        location.reload();
                    });
                }else{
                    layer.msg(data.msg,{icon:2,anim:6,time:1000},function(){
                        layer.close(load);
                    });
                }
            })
        });
    }

    function check() {
        var url = "{:url('/admin/give_time')}";
        var $ = layui.$;
        var load = layer.load(2);
        $.post(url, $("form").serialize(), function (data) {
            if (data.status == 1) {
                layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                    location.reload();
                });
            } else {
                layer.msg(data.msg, {icon: 2, anim: 6, time: 1500}, function () {
                    layer.close(load);
                });
            }
        })
    }
</script>
</body>
</html>


